﻿@using Webdiyer.WebControls.Mvc
@model  Webdiyer.WebControls.Mvc.PagedList<LoveEat.MODEL.sys_menu_series>
    <div class="cont" id="listdata">
        @if (Model != null)
        {

            <table class="table table-responsive table-hover table-striped table-bordered">
                <thead>
                    <tr>
                        <th>

                            <input id="all" name="checkbox1" type="checkbox" value="" onclick="checkboxUdp()" />
                        </th>

                        <th width="6.7">编号</th>
                        <th width="40%">菜品类型</th>
                        <th width="40%">菜品系列</th>
                        <th width="50">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model)
                    {

                        var sys_menu_type = LoveEat.Helper.OperateContext.Current.BLLSession.Isys_menu_typeBLL.GetListBy(s => s.menu_type_id == item.menu_type_id).FirstOrDefault();
                        var menu_series_name = sys_menu_type != null ? sys_menu_type.menu_type_name : "";
                        <tr>
                            <td width="20">  <input type="checkbox" name="checkbox" value="@item.menu_series_id" /></td>

                            <td width="100">@item.menu_series_id</td>
                            <td width="100">@menu_series_name</td>
                            <td>@item.menu_series_name</td>
                            <td width="100">
                                <a class="btn blue mini" href='@Url.Action("MenuCategoriesEdit", new { menu_series_id = item.menu_series_id, returnUrl = Request.Url })'><i class="icon-edit">编辑</i></a>
                                <a class="btn purple mini" href='@Url.Action("DeleteMenuCategories", new { menu_series_id = item.menu_series_id, returnUrl = Request.Url.PathAndQuery })'>删除</a>
                            </td>
                        </tr>

                    }

                </tbody>
            </table>

            <div class="row-fluid">
                @if (Model != null)
                {
                    <div class="span3" id="pagedata">
                        <div class="dataTables_info">共 @Model.TotalItemCount 记录,共 @Model.TotalPageCount 页 </div>
                    </div>

                    <div class="span9">
                        @Ajax.Pager(Model, new PagerOptions { PageIndexParameterName = "PageIndex", ShowPageIndexBox = false, PageIndexBoxType = PageIndexBoxType.DropDownList, ShowGoButton = true, CurrentPagerItemWrapperFormatString = "<a class=\"active\">{0}</a>" }, new MvcAjaxOptions { UpdateTargetId = "listdata", HttpMethod = "Post", DataFormId = "searchform" })

                    </div>
                }
            </div>

        }

        else
        {
            <table class="table table-responsive table-hover table-striped table-bordered">
                <thead>
                    <tr>
                        <th>

                            <input id="all" name="checkbox1" type="checkbox" value="" onclick="checkboxUdp()" />
                        </th>

                        <th width="6.7">编号</th>
                        <th width="7%">菜品类型</th>
                        <th width="40%">菜品系列</th>
                        <th width="50">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model)
                    {

                        <tr>
                            <td width="20">  <input type="checkbox" name="checkbox" value="@item.menu_series_id" /></td>
                            <td width="100">@item.menu_series_id</td>
                            <td width="100">@item.menu_type_id</td>
                            <td>@item.menu_series_name</td>
                            <td width="100">
                                <a class="btn blue mini" href='@Url.Action("Edit", new { id = item.menu_series_id, returnUrl = Request.Url })'><i class="icon-edit">编辑</i></a>
                                <a data-toggle="modal" data-target="#myModal" class="btn purple mini" href='@Url.Action("CaseRemove", new { id = item.menu_series_id, returnUrl = Request.Url.PathAndQuery })'>删除</a>
                            </td>
                        </tr>

                    }

                </tbody>
            </table>
            <div style="  text-align: center;">
                暂无数据
            </div>

        }
    </div>




    <script type="text/javascript">

        //Checkbox全选
        function checkboxUdp() {
            var oInput = document.getElementsByName("checkbox");
            for (var i = 0; i < oInput.length; i++) {
                if (document.getElementById("all").checked == true) {
                    oInput[i].checked = true;
                }
                else {
                    oInput[i].checked = false;
                }
            }
        }


        //批量删除
        function BatchDel() {
     
            var num = 0;
            if ($('input[name="checkbox"]:checked').val() == undefined) {
                $.alert.defaulta('提示', '请选择删除的列');
            }
            else {
                var id = "";
                $.alert.confirm('删除', '是否删除?', function () {
               $('input[name="checkbox"]:checked').each(function () {
                        id += $(this).val() + ',';
                    });
              
           
               if (id != "") {
                 
                    $.ajax({
                        url: "/MenuManagement/DeleteMenuCategoriesList",
                        type: "post",
                        data: { Id: id },
                        success: function (data) {
                           
                            if (data > 0) {
                                $.alert.defaulta('提示', '删除成功', function () {
                                    location.reload();
                                });

                            }
                            else {
                                $.alert.defaulta('提示', '删除失败');
                            }

                        }
                    });
                }
                else {
                    $.alert.defaulta('提示', '请选择删除的列');

                }
                });
            }
        }





    </script>











